<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="author" content="featon inc.">
    <link rel="stylesheet" href="/static/vendor/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/vendor/bootstrap/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="/static/vendor/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/static/vendor/jqPagination/css/jqpagination.css">
    <link rel="stylesheet" href="/static/vendor/datetimepicker/jquery.datetimepicker.css">
    <link rel="stylesheet" href="/static/vendor/skin/ftskin.css">
    <title>HelloWorld</title>
</head>
<body>
<div class="ft-subpage-wrapper container-fluid">
    <div class="row">
        <div class="col-lg-12">
            <div class="tools-box">
                <div class="form-inline">
                    <div class="form-group">
                        <button type="button" class="btn btn-info" onclick="openAddPage()"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 添加</button>
                        <button type="button" class="btn btn-warning" onclick="updateRecord(table,'id','openUpdatePage()');"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span> 修改</button>
                        <button type="button" class="btn btn-success" onclick="sortRecord(table,'id','sortObject()');"><span class="glyphicon glyphicon-floppy-saved" aria-hidden="true"></span> 保存排序</button>
                    </div>

                    <span style="float:right;display:none;">
									<table style="text-align:left;padding-right:5px;float:right" cellspacing="0" cellpadding="0" border="0">
										<tr>
											<td width="195">
												<div class="input-group">
													<input type="text" class="form-control" placeholder="关键字">
													<span class="input-group-btn">
														<button class="btn btn-info" type="button"><span class="glyphicon glyphicon-search" aria-hidden="true"></span> 查询</button>
													</span>
												</div>
											</td>
										</tr>
									</table>
								</span>
                </div>

            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-12" id="table">

        </div>
        <!-- /.col-lg-12 -->
    </div>
    <!-- /.row -->

    <div class="row">
        <div id="turn">

        </div>
    </div>
    <!-- /.row -->

</div>
<script src="/static/vendor/jquery/jquery-3.3.1.min.js"></script>
<script src="/static/vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="/static/vendor/jqPagination/js/jquery.jqpagination.min.js"></script>
<script src="/static/vendor/skin/js/ft-ui.js"></script>
<script src="/static/vendor/skin/js/table-common.js"></script>
<script src="/static/vendor/skin/js/java.js"></script>
<script src="/static/vendor/skin/js/jquery.c.js"></script>
<script>
    var tp = new TurnPage();
    var table = new Table();
    table.table_name = "table_list";
    var beanList = null;
    var con_map = new Map();

    jQuery(function($){
        initTable();
        loadListble()
    });

    function initTable(){

        var colsMap = new Map();
        var colsList = new List();

        colsList.add(setTitleClos("dict_cat_name","字典分类名称","200px","","",""));//英文名，显示名，宽，高，样式名，点击事件　
        colsList.add(setTitleClos("action_col","操作","100px","","",""));
        colsList.add(setTitleClos("dict_cat_id","字典分类代码","150px","","",""));
        colsList.add(setTitleClos("sort_col","排序","100px","","",""));
        colsList.add(setTitleClos("remark","备注","","","",""));
        //colsList.add(setTitleClos("space_col"," ","","","",""));

        //table.checkBox = false;
        table.setColsList(colsList);
        table.setAllColsList(colsList);
        table.enableSort=false;//禁用表头排序
        table.onSortChange = showList;
        table.show("table");//里面参数为外层div的id
    }

    function loadListble()
    {
        showList();
        showTurnPage();
    }

    function showList(){

        beanList = top.ajax.synclBody("/dictCategory/getDictCategoryList",'');
        tp.total = beanList.length;
        curr_bean = null;
        table.setBeanList(beanList,"td_list");//设置列表内容的样式
        table.show("table");



        table.getCol("action_col").each(function(i){
            if(i>0)
            {
                $(this).html('<a href="javascript:openUpdatePage(\''+beanList[i-1].id+'\')">编辑</a>&nbsp;&nbsp;<a href="javascript:deleteSingleObject(\''+beanList[i-1].id+'\',\''+beanList[i-1].dict_cat_id+'\')">删除</a>');
            }
        });

        table.getCol("sort_col").each(function(i){
            if(i>0)
            {
                $(this).html(getSortColStr());
            }
        });

        table_input_init(table.table_name);
    }

    function showTurnPage(){

        tp.show("turn","simple");
        tp.onPageChange = showList;
    }

    function openAddPage()
    {
        modelWindow.openFrameWindow("维护字典分类","/dictCategory/go_dictCate_add",600,330);
    }

    function openUpdatePage(id)
    {
        var sel_id = '';
        if(id != '' && id != null)
        {
            sel_id = id;
        }else
            sel_id = table.getSelecteCheckboxValue("id");
        modelWindow.openFrameWindow("维护字典分类","/dictCategory/go_dictCate_add?dictCate_id="+sel_id,600,330);
    }

    function deleteObject(id,dict_cat_id)
    {
        var dm = new Map();
        dm.put("id",id);
        dm.put("dict_cat_id",dict_cat_id);
        if(top.ajax.syncl("/dictCategory/del", JSON.stringify(dm)))
        {
            modelWindow.alert("字典分类信息"+top.CMSLang.Delete_success);
            loadListble();
        }else
        {
            modelWindow.error("字典分类信息"+top.CMSLang.Delete_fail);
        }
    }

    function deleteSingleObject(id,dict_cat_id)
    {
        modelWindow.confirm("是否删除该条记录","deleteObject('"+id+"','"+dict_cat_id+"')")
    }

    function sortObject()
    {
        var ids = table.getAllCheckboxValue("id");
        if(ids != "" && ids != null)
        {
            let sm = new Map();
            sm.put("id", ids)
            if(top.ajax.syncl("/dictCategory/sort", JSON.stringify(sm)))
            {
                modelWindow.alert(top.CMSLang.Sort_success);
            }
            else
            {
                modelWindow.error(top.CMSLang.Sort_fail);
                return;
            }
        }
    }
</script>
</body>
</html>
